from selenium.webdriver.common.by import By

# --------------------------------------------------以下控制台WEB所有页面元素--------------------------------------------
"""以下为登录页涉及元素 配置信息"""
# 邮箱
login_email_id = (By.ID, "username")
# 密码
login_password_id = (By.ID, "password")
# 登录按钮
login_btn_id = (By.CLASS_NAME, "ant-btn-lg")
# 切换语言按钮
login_lan_btn = (By.CSS_SELECTOR, "button.ant-dropdown-trigger")
# 语言下拉框选项，第一个英文
login_option_first = (By.CSS_SELECTOR, "[class=ant-dropdown-menu-item]:first-child")
# 语言下拉框选项，第二个中文
login_option_second = (By.CSS_SELECTOR, "[class=ant-dropdown-menu-item]:nth-of-type(2)")
# 忘记密码按钮
login_forget_btn = (By.CSS_SELECTOR, "div.dawn-login form div a")
# 忘记密码弹框--E-mail输入框
login_forget_email_input = (By.CSS_SELECTOR, "[placeholder]")
# 忘记密码弹框--确定按钮
login_forget_submit_btn = (By.CSS_SELECTOR, "button.ant-btn-primary")
# 忘记密码弹框--返回登录页按钮
login_forget_back_login = (By.CSS_SELECTOR, "div.back-login a")
# 忘记密码弹框--输入框提示语
login_input_reminder = (By.CSS_SELECTOR, "div.ant-form-explain")
# 已发邮件提示页面--邮箱元素
login_email_reminder = (By.CSS_SELECTOR, "div.color-09")
# 重置密码--密码输入框
login_new_password_input = (By.ID, "newPassword")
# 重置密码--确认密码输入框
login_confirm_password_input = (By.ID, "confirmPassword")
# 163登录按钮
login_type_but = (By.CSS_SELECTOR, "a.u-163-login-entry")
# 163登录表单
login_frame = (By.TAG_NAME, "iframe")
# 163邮箱输入框
login_163_email = (By.NAME, "email")
# 163密码输入框
login_163_pwd = (By.NAME, "password")
# 163登录按钮
login_163_but = (By.ID, "dologin")
# 163邮件内容表单
login_reset_frame = (By.CSS_SELECTOR, "[class='oD0']")
# 163邮件内重置密码url
login_reset_url = (By.XPATH, "//div[@id='content']/div/div/div[5]/a")
# 登录标题文本元素
login_page_login_text = (By.CSS_SELECTOR, "div.vGhcB h3")
# 语言按钮文本元素
login_lan_btn_text = (By.CSS_SELECTOR, "button.ant-dropdown-trigger span")
# 控制台文本元素
login_console_btn_text = (By.CSS_SELECTOR, "header.ant-layout-header span:nth-of-type(2)")

"""以下数据为导航模块配置数据"""
# 账户名显示
gps_account_look = (By.CSS_SELECTOR, "span.ant-dropdown-trigger:first-child")
# 退出登录
gps_logout_btn = (By.CSS_SELECTOR, "li.ant-dropdown-menu-item")
# 应用列表
gps_app_list_btn = (By.CSS_SELECTOR, "[role=menu] li:nth-of-type(2)")
# 设备管理
gps_device_man_btn = (By.CSS_SELECTOR, "[role=menu] li:nth-of-type(4)")
# 设备列表
gps_dev_list_btn = (By.CSS_SELECTOR, "[class=ant-menu-item]:nth-of-type(1) a")
# 升级列表
gps_up_list_btn = (By.CSS_SELECTOR, "[class=ant-menu-item]:nth-of-type(2) a")

"""以下为应用列表页配置数据"""
# 创建应用按钮
app_create_btn = (By.CSS_SELECTOR, "[type=button]:first-child")
# 应用名称输入框
app_name_input = (By.ID, "appName")
# 更新说明输入框
app_description_input = (By.ID, "description")
# 输入框下方提示语
app_input_explain = (By.CSS_SELECTOR, "div.ant-form-explain")
# 应用列表页应用名称-用于定位所有应用名称
app_list_names_ele = (By.CSS_SELECTOR, "tbody tr td:nth-of-type(2)")
# 应用列表页应用描述-用于定位所有应用描述
app_list_descriptions_ele = (By.CSS_SELECTOR, "tbody tr td:nth-of-type(7) span")
# 确定按钮
app_accept_btn = (By.CSS_SELECTOR, "div.modal-footer button.ant-btn-primary")
# app_accept_btn = (By.CSS_SELECTOR, "div.ant-modal-footer button.ant-btn-primary")

# 取消按钮
app_cancel_btn = (By.CSS_SELECTOR, "div.modal-footer [class=ant-btn]")

"""以下为设备列表页配置数据"""
# 设备空间搜索框
space_search_input = (By.CSS_SELECTOR, "div.input-search-div input")
# 设备空间名称输入框
space_name_input = (By.ID, "spaceName")
# 所有添加设备空间按钮
space_create_btns = (By.CSS_SELECTOR, "span.add-space img")
# 所有应用名
space_app_names = (By.CSS_SELECTOR, "span.space-first-title span.text-content")
# 所有设备空间名-展开的应用
space_names = (By.CSS_SELECTOR, "div.space-two-title span.text-content")
# 所有设备空间名后的统计台数-展开的应用
space_ipc_nums = (By.CSS_SELECTOR, "div.space-two-title span.text-num")
# 所有编辑设备空间按钮-展开的应用
space_edit_btns = (By.CSS_SELECTOR, "div.space-two-title span:nth-of-type(3) span:first-child")
# 所有删除设备空间按钮-展开的应用
space_del_btns = (By.CSS_SELECTOR, "img.width16")

# 设备列表头显示的space_id
dev_list = (By.CSS_SELECTOR, "[class=info-block] span:last-child")
# 移动到按钮
dev_move_space_btn = (By.CSS_SELECTOR, "div.remove-ipc button")
# 调参按钮
dev_param_btn = (By.CSS_SELECTOR, "div.config-ipc button")
# 升级按钮
dev_upgrade_btn = (By.CSS_SELECTOR, "div.upgrade-ipc button")
# 移除按钮
dev_remove_btn = (By.CSS_SELECTOR, "div.unbind-ipc button")
# 移动设备弹框---设备空间下拉框
dev_space_select = (By.CSS_SELECTOR, "div#spaceId [role]")
# 升级设备弹框---OTA版本下拉框
dev_version_select = (By.CSS_SELECTOR, "div#otaId [role]")
# 设置页面---所有阈值输入框
dev_config_threshold_inputs = (By.CSS_SELECTOR, "[aria-valuemax='100'] [max='100']")
# 设置页面---第一个阈值输入框
dev_first_threshold_input = (By.CSS_SELECTOR, "form.ant-form-horizontal  div.ant-row:nth-of-type(3) input")
# 设置页面---第二个阈值输入框
dev_second_threshold_input = (By.CSS_SELECTOR, "form.ant-form-horizontal  div.ant-row:nth-of-type(4) input")
# 设置页面---识别功能开关
dev_config_recog_btn = (By.CSS_SELECTOR, "button.ant-switch")
# 设置页面---识别功能开关文本
dev_config_open_recog = (By.CSS_SELECTOR, "span.ant-switch-inner")
# 设置页面---保存按钮
dev_config_save_btn = (By.CSS_SELECTOR, "div.ant-modal-body button.ant-btn-primary")
# 设置页面---取消按钮
dev_config_canal_btn = (By.CSS_SELECTOR, "div.ant-modal-body [class=ant-btn]")
# 设备列表搜索框
dev_search_input = (By.CSS_SELECTOR, "input[placeholder*=SN]")
# 设备列表搜索框放大镜按钮
dev_search_btn = (By.CSS_SELECTOR, "span.search-img img")
# 设备型号下拉框
dev_type_select = (By.CSS_SELECTOR, "span.operation-content-right div.ant-select-selection__rendered")
# 编辑IPC位置输入框
dev_edit_position_input = (By.CSS_SELECTOR, "span.ant-form-item-children input")
# 操作详细信息中第一个操作的信息
dev_first_status_text = (By.CSS_SELECTOR, "div.ant-modal-header + div [data-row-key]:first-child td")
# 操作详细信息中第二个操作的信息
dev_second_status_text = (By.CSS_SELECTOR, "div.ant-modal-header + div [data-row-key]:nth-of-type(2) td")
# 删除线按钮
dev_del_line_btns = (By.CSS_SELECTOR, "button.ant-btn-sm:nth-of-type(2)")
# 删除域按钮
dev_del_area_btn = (By.CSS_SELECTOR, "div.ant-tag-has-color path")
# 图片刷新按钮
dev_img_refresh_btn = (By.CSS_SELECTOR, "i.icon-image svg")
# 设置--开启区域抓拍
dev_enable_box = (By.CSS_SELECTOR, "input#switchregion")
# 设置页面---绘制单选按钮
dev_config_lines_btn = (By.CSS_SELECTOR, "input.ant-radio-input")

# 调参弹框---灵敏度
prarm_track_score_eliminate = (By.CSS_SELECTOR, "div#sensitivity [role]")
# 调参弹框---目标抓拍时间
prarm_beginpostframethr = (By.CSS_SELECTOR, "div#graspTime [role]")
# 是否重复抓拍-已点击的
prarm_if_re_in = (By.XPATH, "//*[@class='ant-radio ant-radio-checked']/input")
# 是否重复抓拍-未点击的
prarm_if_re_off = (By.XPATH, "//*[@class='ant-radio']/input")
# 调参弹框 - --再次抓取时间差
prarm_resnapthr = (By.CSS_SELECTOR, "div#reGraspTime [role]")
# 抓拍图片数输入框
prarm_firstnumavailthr = (By.CSS_SELECTOR, "[aria-valuemax='3'] [max='3']")
# 调参弹框---抓拍阈值
prarm_frontthr = (By.CSS_SELECTOR, "div#graspValue [role]")
# 人脸外廓系数输入框
prarm_snapscale = (By.CSS_SELECTOR, "[aria-valuemax='4'] [max='4']")
# 抓拍最小人脸尺寸
prarm_snapsizethr = (By.CSS_SELECTOR, "[aria-valuemax='256'] [max='256']")

"""以下为升级列表页配置数据"""
# 上传OTA包按钮
up_loading_ota_btn = (By.CSS_SELECTOR, "div.btn-list button")
# IPC机型下拉框
up_type_select = (By.CSS_SELECTOR, "div#otaType>div")
# 上传文件按钮
up_file_btn = (By.CSS_SELECTOR, "span.ant-upload>input")
# 升级版本名称
up_version_name = (By.CSS_SELECTOR, "#otaVersion")
# 升级更新说明
up_description = (By.CSS_SELECTOR, "#description")
# 页面所有ota版本
up_ota_versions = (By.CSS_SELECTOR, "tr.ant-table-row td:nth-child(2)")
# 第一个删除按钮
up_first_del_but = (By.XPATH, "//tbody[@class='ant-table-tbody']/tr[1]/td/span[@class='operation']")
# 设备列表搜索框
up_ota_search_input = (By.CSS_SELECTOR, "input[placeholder*=OTA]")
# 升级列表下拉框
up_ota_select_btn = (By.CSS_SELECTOR, "span.ant-input-affix-wrapper + div [role]")
# 升级列表所有类型字段
up_ota_type_text = (By.CSS_SELECTOR, "tr.ant-table-row-level-0 td:nth-of-type(3)")
# ota版本名称输入框下方提示语
up_ota_input_reminder = (By.CSS_SELECTOR, "div.ant-form-explain")

"""以下为通用页面元素"""
# [type=button]用于找出所有button,通过value/index点击指定元素
com_buttons = (By.CSS_SELECTOR, "[type=button]")
# [role=option]
com_options = (By.CSS_SELECTOR, "[role=option]")
# 关闭弹出框按钮
com_close_box_btn = (By.CLASS_NAME, "ant-modal-close-x")
# 页面toast消息
com_page_toast = (By.CSS_SELECTOR, "div.ant-message-notice-content div span")
# 确定按钮
com_accept_btn = (By.CSS_SELECTOR, "div.ant-modal-footer button.ant-btn-primary")
# 取消按钮
com_cancel_btn = (By.CSS_SELECTOR, "div.ant-modal-footer [class=ant-btn]")
# 知道了按钮
com_know_btn = (By.CSS_SELECTOR, "div.ant-modal-confirm-btns button")
# 下拉中选项-第一个
com_option_first = (By.CSS_SELECTOR, "[role=option]:first-child")
# 下拉中选项-第二个
com_option_second = (By.CSS_SELECTOR, "[role=option]:nth-of-type(2)")
# 下拉中选项-第三个
com_option_third = (By.CSS_SELECTOR, "[role=option]:nth-of-type(3)")
# 下拉中选项-第四个
com_option_four = (By.CSS_SELECTOR, "[role=option]:nth-of-type(4)")
# 选择每页显示条数下拉框
com_sel_page_num_btn = (By.CSS_SELECTOR, "div.ant-select-selection-selected-value")

# ------------------------------------------------以下设备开通telnet使用------------------------------------------------
"""开通telnet所需pwd及auth"""
devices_ip = [
    {"device_ip": "10.64.31.43", "pwd": "5F3E13C87ADC", "auth": "Basic THVja3k3ODc6NUYzRTEzQzg3QURD"},
    {"device_ip": "10.64.31.49", "pwd": "EA730D0E5B1F", "auth": "Basic THVja3k3ODc6RUE3MzBEMEU1QjFG"},
    {"device_ip": "10.64.31.56", "pwd": "624E8911BBFB", "auth": "Basic THVja3k3ODc6NjI0RTg5MTFCQkZC"},
    {"device_ip": "10.64.31.57", "pwd": "8F5D6EE81F97", "auth": "Basic THVja3k3ODc6OEY1RDZFRTgxRjk3"},
    {"device_ip": "10.64.31.50", "pwd": "1F5FFC3EB552", "auth": "Basic THVja3k3ODc6MUY1RkZDM0VCNTUy"},
    {"device_ip": "10.64.31.53", "pwd": "A60B304ABE66", "auth": "Basic THVja3k3ODc6QTYwQjMwNEFCRTY2"},
    {"device_ip": "10.64.31.58", "pwd": "95EDCD7F2462", "auth": "Basic THVja3k3ODc6OTVFRENEN0YyNDYy"},
    {"device_ip": "10.64.31.47", "pwd": "122511C9BC70", "auth": "Basic THVja3k3ODc6MTIyNTExQzlCQzcw"},
    {"device_ip": "10.64.31.55", "pwd": "7036E80D75E8", "auth": "Basic THVja3k3ODc6NzAzNkU4MEQ3NUU4"},
    {"device_ip": "10.64.31.42", "pwd": "42F0887750D7", "auth": "Basic THVja3k3ODc6NDJGMDg4Nzc1MEQ3"},
    # {"device_ip": "10.64.31.59", "pwd": "7036E80D75E8", "auth": "Basic THVja3k3ODc6NzAzNkU4MEQ3NUU4"},
]
